package com.py.credit.common.rest;

import java.io.IOException;

import org.springframework.http.HttpOutputMessage;
import org.springframework.http.converter.HttpMessageNotWritableException;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;

/**
 * 自定义返回结果解析
 * 
 * @author Leegern
 * @date 2018年3月15日
 */
public class ExtMappingJackson2HttpMessageConverter extends MappingJackson2HttpMessageConverter {

	@SuppressWarnings({ "rawtypes", "unchecked" })
	@Override
	protected void writeInternal(Object object, HttpOutputMessage outputMessage)
			throws IOException, HttpMessageNotWritableException {
		if (object != null && object.toString().contains("springfox.documentation")) {// swagger
			super.writeInternal(object, outputMessage);
			return;
		}
		super.writeInternal(new RestServiceResult(object), outputMessage);
	}
}
